package com.lmb.service.impl;

import com.lmb.bean.Residents;
import com.lmb.mapper.ResidentsDao;
import com.lmb.service.ResidentsService;
import com.lmb.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ResidentsServiceImpl implements ResidentsService {
    @Autowired
    ResidentsDao residentsDao;

    @Override
    public Residents add(Residents residents) {
        residentsDao.add(residents);
        Residents result=residentsDao.one(residents.getResident_id());
        return result;
    }

    @Override
    public Residents edit(Residents residents) {
        residentsDao.edit(residents);
        Residents result=residentsDao.one(residents.getResident_id());
        return result;
    }

    @Override
    public int del(Integer id) {
        return residentsDao.del(id);
    }

    @Override
    public Residents one(Integer id) {
        return residentsDao.one(id);
    }

    @Override
    public List<Residents> all(Residents residents) {

        return residentsDao.all(residents);
    }

    @Override
    public void page(Page page, Residents residents) {
        int count= residentsDao.pageCount(residents);
        Object data= residentsDao.page(page, residents);
        page.setCount(count);
        page.setData(data);
    }
}
